<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Model extends CI_Model{
    public function __construct() {
        parent::__construct();
    }
    
    public function _serialize($data){
        
        if(is_array($data)){
            foreach($data as $key=>$value){
                $data[$key] = str_replace(array('\\'),array('{{slash}}'),$value);
                
            }
        }
        else{
            $data = str_replace('\\','{{slash}}',$data);
        }
        return serialize($data);
    }
    
    public function _unserialize($data){
        $data = unserialize(stripslashes(trim($data)));
        if(is_array($data)){
            foreach ($data as $key => $val)
			{
				$data[$key] = str_replace(array('{{slash}}'), array('\\'), $val);
			}
                return $data;
        }
        return str_replace(array('{{slash}}'), array('\\'), $data);;
        
    }
}